package org.hongzhisoft.dis.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hongzhisoft.dis.service.UserService;
import org.hongzhisoft.dis.service.impl.UserServiceImpl;

/**
 * 用户删除操作处理类
 * @author HongChengzhi
 *
 */
@WebServlet("/user/delete")
public class UserDeleteServlet extends HttpServlet {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private UserService userService = new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

        int id =  Integer.parseInt(req.getParameter("id"));
        String account =  req.getParameter("account");

        try {
             userService.deleteUser(id);
             req.setAttribute("account", account);
             req.getRequestDispatcher("/delete_success.jsp").forward(req, resp);
             
        } catch (Exception e) {
            throw new ServletException(e);
        }
        


    }

}
